<template lang="html">
  <div>
    <div class="search">
        <div class="input">
      <p>
				<label>提现状态:</label>
				<el-select placeholder="请输入内容" v-model="orderStatus">
						<el-option value="">请选择</el-option>
						<el-option
							v-for="(item,key) in orderList"
							:key="key"
							:label="item.label"
							:value="item.value"
						></el-option>
				</el-select>
			</p>
        <p>
          <label>转账手动处理结果:</label>
          <el-select placeholder="请输入内容" v-model="searchData.funsResult">
              <el-option value="">请选择</el-option>
              <el-option
                v-for="(item,key) in funsResult"
                :key="key"
                :label="item.label"
                :value="item.value"
              ></el-option>
          </el-select>
        </p>
          <p><label>外部交易号：</label><el-input placeholder="请输入内容" v-model="searchData.outTradeNo" ></el-input></p>
            <p><el-button type="primary" class="se" @click="searchOrder()" style="margin-left:10px;">搜索</el-button></p>
        </div>
    </div>
    <!-- <div class="add">
       <el-button type="primary" @click="add">新增货单</el-button>
    </div> -->
    <tableVue :list="list" :state="false" @sizeChange="handleSize" :total="total" v-loading='loading'>
        <slot>
          <el-table-column label="操作" align="center">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="primary"
                  class="del"
                  @click="handleEdit(scope.$index, scope.row)">详情</el-button>
              </template>
          </el-table-column>
        </slot>
    </tableVue>

  </div>
</template>

<script>
import Data from './drawMoneyData.js'
import tableVue from '@/components/alltable.vue'
import {
  getMoneyList,getMoneyDetails,getMoney
} from "@/api/payCenter/payCenter";
export default {
  components : {
    tableVue
  },
   data () {
     return JSON.parse(JSON.stringify(Data))
   },
   mounted () {
	 this.getMoneyLists({current:1,size:10});
   },
   methods : {
     getMoneyLists (data) {
         this.loading =true;
       getMoneyList(data).then(res=>{
           if(res.data.code=="OK"){
               this.loading =false
               this.list.tbody = res.data.data.records.map(res=>{
                   res.amount = res.amount /100;
                   switch(res.funsStatus){
                        case "CREATEED":
                            res.funsStatus = "订单生成";
                            break;
                        case "FUNDING":
                            res.funsStatus = "代付中";
                            break;
                        case "SUCCESS":
                            res.funsStatus = "代付成功";
                            break;
                        case "FAILED":
                            res.funsStatus = "代付失败";
                            break;
                        case "COMPLETE":
                            res.funsStatus = "代付业务处理完成";
                            break;

                   }
                   return res

               });
               this.total = res.data.data.total;
           }
       })
	 },
	 handleSize(size){
		  let data ={
			 current:size,
			 size:10
         }
         this.orderStatus&&(data.funsStatus=this.orderStatus);
		 this.getMoneyLists(data)
	 },
     changeData (data) {
       this.dialog = data;
     },
	 searchOrder(){
		 let data ={
             funsStatus:this.orderStatus,
             current:1,
			        size:10,
              funsResult : this.searchData.funsResult,
              outTradeNo : this.searchData.outTradeNo
		 }
		 this.getMoneyLists(data)
     },
     giveMoney(data){ //提现
         let res ={
             funsOrderId:data.funsOrderId,
             funsStatus:data.funsResult
         }

         this.$confirm('确定提现?',"提示",{
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
         }).then(()=>{
            getMoney(res).then(res=>{
                if(res.data.code=="OK"){
                     this.$message({
                        type: 'success',
                        message: '提现成功!'
                    });
                }else{
                    this.$message.error(res.data.message)
                }
            })

         })
     },
     handleEdit(index,data){
         this.$router.push({name:'drawDetails',query:{id:data.funsOrderId}})
     }

   }
}
</script>

<style scoped>
  @import "../../../styles/common.css";
</style>
